package com.dream.cloud.controller;

import cn.hutool.core.date.DateUtil;
import com.dream.cloud.api.PayFeignApi;
import com.dream.cloud.entities.PayDTO;
import com.dream.cloud.resp.ResultData;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
public class OrderController {


    @Resource
    private PayFeignApi payFeignApi;


    /**
     * 下单
     * @param payDTO
     * @return
     */
    @PostMapping("/feign/pay/add")
    public ResultData addOrder(@RequestBody PayDTO payDTO) {
        return payFeignApi.addPay(payDTO);
    }

    /**
     * 获取所有支付流水
     *
     * @return
     */
    @GetMapping("/feign/pay/get/{id}")
    public ResultData getPayInfo(@PathVariable("id") Integer id) {

        ResultData rd = null;

        try {
            System.out.println("====调用开始" + DateUtil.now());
            rd = payFeignApi.getById(id);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("====调用结束" + DateUtil.now());
        }

        return rd;
    }

    @GetMapping(value = "/feign/pay/getConfig")
    private String getConfigByConsul()
    {
        return payFeignApi.getConfig();
    }




}
